<template>
  <div class="banner">
    <div class="swiper-container">
      <div class="swiper-wrapper">
        <div class="swiper-slide" v-for="item in banners" v-bind:key="item.id">
          <a href="#" class="link">
            <img :src="item.src" alt="" />
          </a>
        </div>
      </div>
      <!-- 分页器 -->
      <div class="swiper-pagination"></div>
    </div>
  </div>
</template>

<script>
// 注意引入的是Swiper
import Swiper from "swiper";
// 注意这里的引入
import "swiper/css/swiper.min.css";
export default {
  name: "banner",
  data() {
    return {
      banners: [
        {
          id: 1,
          src: require("../static/images/Card.png"),
        },
        {
          id: 2,
          src: require("../static/images/Card.png"),
        },
        {
          id: 3,
          src: require("../static/images/Card.png"),
        },
      ],
    };
  },
  mounted() {
    var mySwiper = new Swiper(".swiper-container", {
      // config...
      pagination: {
        el: ".swiper-pagination",
      },
    });
  },
};

// 文档地址:https://blog.csdn.net/tuzi007a/article/details/122646552
</script>

<style lang="less">
@import "../static/less/variable.less";
.banner {
  width: 100%;
  padding: @pad;
  .link {
    display: block;
    width: 100%;
    padding-top: 15px;
    padding-bottom: 30px;
    img {
      width: 100%;
    }
  }
  .swiper-container {
    width: 100%;
  }
  .swiper-pagination {
    transform: translateY(6px);
  }
  /*小圆点的样式*/
  .swiper-pagination-bullet {
    margin-left: 5px;
    background-color: @bgPointBg;
    opacity: .85 !important;
    &.swiper-pagination-bullet-active {
      width: 10px;
      height: 10px;
      border-radius: 50%;
      background-color: @bgColor;
    }
  }
}
</style>
